<?php
/**
 * Created by PhpStorm.
 * User: xuhongyi
 * Date: 2019/10/25
 * Time: 15:43
 */
session_start();
require './conn.php';
$username=$_POST['username'];
$password=$_POST['password'];
$sql="select * from user where username='$username' and password='$password'";
$query=mysqli_query($conn,$sql);
if (mysqli_num_rows($query)){
    $assoc=mysqli_fetch_assoc($query);
    $user_info=json_encode($assoc);
    $session_key=session_id();
    $redis=new Redis();
    $redis->connect('localhost', 6379, 30);
    $redis->auth('zxc86506859');
    $redis->set($session_key,$user_info);
    $_SESSION['username']=$assoc['username'];
    if (!empty($_POST['server'])){
        header('Location:http://'.$_POST['server'].'?access_token='.$session_key);
    }else{
         header('Location:/success.php');
    }
}
